<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>私家之旅 - 管理后台</title>
<link href="css/css/login.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="assets/jquery-1.7.2.min.js"></script>
</head>

<body>
	<div id="login">
		<div id="login_header">
			<h1 class="login_logo">
				<a href="#"><img src="css/default/images/login_logo.png" /></a>
			</h1>
			<div class="login_headerContent">
				<div class="navList">
				</div>
				<h2 class="login_title"><img src="css/default/images/login_title.png" /></h2>
			</div>
		</div>
		<div id="login_content">
			<div class="loginForm">
					<p>
						<label>用户名：</label>
						<input type="text" name="username" id="username" size="30" style="width:150px" class="login_input" />
					</p>
					<p>
						<label>密码：</label>
						<input type="password" name="password" id="password" style="width:150px" class="login_input" />
					</p>
					<p>
						<label>验证码:</label>
						<input class="code" type="text" id="chkcode" size="7" style="width:75px" />
						<span><img src="<?php echo Yii::app()->createUrl('site/captcha');?>" onclick="this.src='<?php echo Yii::app()->createUrl('site/captcha');?>&'+Math.random()" alt="点击刷新验证码" title="点击刷新验证码"width="70" height="26" style="cursor:pointer"/></span>
					</p>
					<div class="login_bar">
						<input class="sub" type="submit" id="loginbtn" value=" " />
					</div>
			</div>
			<div class="login_banner"><img src="css/default/images/login_banner.jpg" /></div>
			<div class="login_main">
			</div>
		</div>
		<div id="login_footer">
			Copyright &copy; 2015 admin.sijiazhilv.com Inc. All Rights Reserved.
		</div>
	</div>
</body>
<script>
$(function(){
	$("#loginbtn").click(function (){
	var username = $.trim($("#username").val());
	var pass = $.trim($("#password").val());
	var code = $.trim($("#chkcode").val());
	if(username == ""){
		alert("请输入用户名");
		$("#username").focus();
		return false;
	}
	if( pass == ""){
		alert("请输入用户密码");
		$("#password").focus();
		return false;
	}
	if( code == ""){
		alert("请输入验证码");
		$("#chkcode").focus();
		return false;
	}
	$.ajax({
		url:"<?php echo Yii::app()->createUrl('site/doLogin');?>",
		type:"POST",
		dateType:"json",
		data:{
			loginForm:{
			username:username,
			password:pass,
			chkcode:code}
		},
		timeOut:5000,
		beforeSend:function(){
			$("#loginbtn").attr("disabled", true);
		},
		complete:function(){
			$("#loginbtn").attr("disabled", false);
		},
		error:function(data){
			alert("未知错误");
		},
		success:function(data){
			if(data.statusCode == 200){
				location.href = "/";
			}else{
				$("img").trigger("onclick");
				alert(data.message);
			}
		}
	});
})
});

</script>
</html>